<?php
/**
 * Created by PhpStorm.
 * User: 70791
 * Date: 2020/7/28
 * Time: 14:07
 */

namespace App\HttpController\Api;

use EasySwoole\Component\Di;
use priestll\easyswoole\http\Auth;

class Order extends Auth
{

    /**
     * @Di(key="ORDER_BIZ")
     */
    protected $biz;

    /**
     * @Api(name="getOrderRanking",group="/api/order",description="当前用户活动轮数排行榜",path="/api/order/getOrderRanking")
     * @ApiAuth(name="authorization",type=string,from={'HEADER'},description="token")
     * @Method(allow={GET})
     * @ResponseParam(name="code",description="状态码")
     * @ResponseParam(name="result",description="api请求结果")
     * @ResponseParam(name="msg",description="api提示信息")
     * @ApiSuccess({"code":200,"result":[],"msg":"SUCCESS"})
     * @ApiFail({"code":400,"result":[],"msg":"FAIL"})
     * @Param(name="page",alias="当前页数",integer="")
     */
    public function getOrderRanking()
    {
        $user = $this->getUser();
        $param = $this->request()->getRequestParam();
        $res = $this->biz->getRanking($user["round"],$param["page"]);
        if ($res['status']) {
            return $this->success($res['data']);
        } else {
            return $this->fail($res['data']);
        }
    }


    /**
     * @Api(name="confirmNextRound",group="/api/order",description="确定下一轮",path="/api/order/confirmNextRound")")
     * @Method(allow={GET})
     * @ResponseParam(name="code",description="状态码")
     * @ResponseParam(name="result",description="api请求结果")
     * @ResponseParam(name="msg",description="api提示信息")
     * @ApiSuccess({"code":200,"result":[],"msg":"SUCCESS"})
     * @ApiFail({"code":400,"result":[],"msg":"FAIL"})
     */
    public function confirmNextRound()
    {
        $user = $this->getUser();
        $res = $this->biz->confirm($user["id"]);
        return $this->success($res);
        if ($res['status']) {
            return $this->success($res['data']);
        } else {
            return $this->fail($res['data']);
        }
    }
}